#include "StdAfx.h"
#include "STL_Buffer.h"

#include <fstream>

using namespace std;

STL_Buffer::STL_Buffer(const char* srcFile)
{
    file = ifstream(srcFile, ifstream::in);
}


STL_Buffer::~STL_Buffer(void)
{
    //delete file;
}


int STL_Buffer::getchar()
{
    char c;
    file.get(c);
    if(file.eof())
        return -1;
    return c;
}

void STL_Buffer::ungetchar(size_t times /*= 1*/)
{
    char c = file.get();
    for(size_t i = 0; i < times; ++i)
    {
        file.unget();
    }
    c = file.get();
}